package cn.wolfcode.trip.app.controller;
import cn.wolfcode.trip.base.domain.Ticket;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.TravelCommendQueryObject;
import cn.wolfcode.trip.base.service.ITicketService;

import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.net.URLDecoder;
import java.util.List;

@RestController
@RequestMapping("/tickets")
public class TicketController {
    @Autowired
    private ITicketService ticketService;


    @GetMapping
    public PageInfo getTicket(QueryObject qo){
        qo.setOrderBy("price desc");
        qo.setPageSize(4);
        PageInfo pageInfo = ticketService.query(qo);
        return pageInfo;
    }

    @PutMapping
    public JSONResult update(Ticket entity){
        JSONResult result=new JSONResult();
        ticketService.updateState(entity);
        return result;
    }


    @GetMapping("/business")
    public List getTicket(Ticket entity){
        List tickets = ticketService.queryAllByState(entity);

        return tickets;
    }

}
